<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>[Generic Component Framework v3] GCF Fiber</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<!--link href="tabs.css" rel="stylesheet" type="text/css"-->
</head><body>
 <div id="wrapper">
    <div id="logo_box">
        <a class="img_link" href="https://github.com/pnudupa/gcf" target="_blank" ><img style="float:left;margin-left:10px;margin-top:5px;margin-bottom:5px;"src="header_gcf_logo.jpg" alt="GCF LOGO"/></a>
        <a class="img_link" href="https://www.vcreatelogic.com/" target="_blank" ><img style="float:right;margin-right:10px; margin-top: 30px;" src="header_vcl_logo.jpg" alt="VCL LOGO"/></a>
        <div style="clear:both"></div>
    </div>
    <div class="nav">
        <ul>
            <li class="selectedpage">
                <a class="a-home" href="index.html" >
                    <span>Home</span>
                </a>
            </li>
            <li>
                <a class="a-classes " href="classes.html">
                    <span>All Classes</span>
                </a>
            </li>
            <li>
                <a class="a-home " href="gcf_modules.html">
                    <span>Modules</span>
                </a>
            </li>
            <li>
                <a class="a-home " href="gcf_guides_and_videos.html">
                    <span>Guides & Videos</span>
                </a>
            </li>
            <li>
                <a class="a-home " href="gcf_tools_and_inbuilt_components.html">
                    <span>Tools & Components</span>
                </a>
            </li>
        </ul>
    </div>
    <div id="main-content">
        <div class="inside">
        <div>
<!-- Generated by Doxygen 1.8.16 -->
</div><!-- top -->
<div class="PageDoc"><div class="header">
  <div class="headertitle">
<div class="title">GCF Fiber </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>Fiber is a collection of tools provided as a part of GCF 3, which would help you host a component developed in GCF 3 <b>like a web service.</b> A client written in <b>any technology</b> on <b>any platform</b> can then access the exposed services as long as they follow a simple <b>JSON message format.</b></p>
<p> 
<div style="border: 1px solid black; padding: 20px; margin: 20px; font-size: 1.25em;">
GCF Fiber is no longer guaranteed to work in 2019. The source code & documentation is provided only if you
want to use it as an inspiraton to build your own stack. By default GCF's Fibre module is not compiled
along with GCF. You have to explicitly enable compilation of these modules.
</div>
</p>
<h1><a class="anchor" id="gcf_fiber_0"></a>
Introduction</h1>
<hr  />
<p>This article illustrates how Fiber can be used to provide the methods in components as web services; and the message format a client needs to use, to have a meaningful communication with Fiber.</p>
<ul>
<li><a class="el" href="gcf_fiber.html#gcf_fiber_1">Setting up Fiber at the server</a> </li>
<li><a class="el" href="gcf_fiber.html#gcf_fiber_2">Starting and stopping Fiber</a> </li>
<li><a class="el" href="gcf_fiber.html#gcf_fiber_3">Authoring components with services</a> </li>
<li><a class="el" href="gcf_fiber.html#gcf_fiber_4">Fiber message format</a> </li>
<li><a class="el" href="gcf_fiber.html#gcf_fiber_5">Accessing Fiber using the message format</a> </li>
<li><a class="el" href="gcf_fiber.html#gcf_fiber_6">Advanced tweaking</a></li>
</ul>
<h1><a class="anchor" id="gcf_fiber_1"></a>
Setting up Fiber at the server</h1>
<hr  />
<ul>
<li>First thing to do, is to get the GCF 3 development environment ready. Refer to GCF 3's FAQ document to read about the same.</li>
<li>Next you would need a web server. Ideally any thing that can run PHP would do just fine. But its worth mentioning here that we have tested it only with <b> Apache on Linux, and Windows.</b></li>
<li>Update the document root of the web server to point to <b><em> path-to-GCF3/Fiber/Fiber/Scripts </em></b> where you must find the PHP files of the Fiber.</li>
<li>Write your web service classes and expose them via writing a GCF component. See <a class="el" href="gcf_fiber.html#gcf_fiber_3">Authoring components with services</a></li>
<li>Update system path with the location of the library files for your component so that it can be found by Fiber when required (Components will be loaded by Fiber only when a client tries to access it for the first time)</li>
<li>Test your set-up by running <b><em> path-to-GCF3/Tests/UnitTests/FiberTest </em></b>. If the tests work fine, your set-up is fine.</li>
</ul>
<h1><a class="anchor" id="gcf_fiber_2"></a>
Starting and stopping Fiber</h1>
<hr  />
<p> Fiber can be started/stopped using the command line utility <b> FiberCtl </b> that comes with Fiber.</p>
<ul>
<li>Start Fiber by executing the following command <br  />
<br  />
 <code><b> FiberCtl start </b> </code> <br  />
<br  />
 Now clients should be able to access the web services provided by your component/s over the web! <br  />
<br  />
</li>
<li>Stop Fiber by executing the following command <br  />
<br  />
 <code><b> FiberCtl stop </b> </code> <br  />
<br  />
 Also <code><b> FiberCtl status </b> </code> can be used to find out whether Fiber is already running or not</li>
</ul>
<h1><a class="anchor" id="gcf_fiber_3"></a>
Authoring components with services</h1>
<hr  />
<p>In Fiber the web services should be provided through dynamically loadable components. These are normal GCF 3 components with the following rules</p><ul>
<li>The component should be available in a library file</li>
<li>All exposed <b> objects </b> in the component that intends to offer services should have <b> allowmetaaccess </b> property set to <b>true</b></li>
<li>Only <b> public </b> methods that are <b>invokable (Q_INVOKABLE, slots)</b> in exposed objects would be accessible as services.</li>
</ul>
<p>The components that host the web services could either be <b> Core </b> or <b> Gui </b> components. </p><ul>
<li><a class="el" href="gcf_fiber.html#gcf_fiber_3_sub0">Sample core service component</a> </li>
<li><a class="el" href="gcf_fiber.html#gcf_fiber_3_sub1">Sample gui service component</a></li>
</ul>
<dl class="section note"><dt>Note</dt><dd>It is strongly adviced that the gui components written to be loaded by Fiber doesn't call show on any widgets. This would make automatic recovery from crash difficult.</dd></dl>
<h2><a class="anchor" id="gcf_fiber_3_sub0"></a>
Sample core service component</h2>
<p>In SimpleCoreComponent.h</p>
<div class="fragment"><div class="line"><span class="preprocessor">#include &lt;GCF3/Component&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;GCF3/Application&gt;</span></div>
<div class="line"> </div>
<div class="line"><span class="keyword">class </span>SimpleCoreComponent : <span class="keyword">public</span> <a class="code" href="class_g_c_f_1_1_component.html">GCF::Component</a></div>
<div class="line">{</div>
<div class="line">    Q_OBJECT</div>
<div class="line"> </div>
<div class="line"><span class="keyword">public</span>:</div>
<div class="line">    SimpleCoreComponent(QObject *parent=0)</div>
<div class="line">        : GCF::<a class="code" href="class_g_c_f_1_1_component.html#a0a8e6280e3029cab1db39d4a0b0cdf11">Component</a>(parent) {</div>
<div class="line">    }</div>
<div class="line"> </div>
<div class="line">    Q_INVOKABLE <span class="keywordtype">void</span> dummyService() { }</div>
<div class="line"> </div>
<div class="line"><span class="keyword">protected</span>:</div>
<div class="line">    <span class="keywordtype">void</span> <a class="code" href="class_g_c_f_1_1_component.html#a75422842587613d43844e73fb8ca021d">initializeEvent</a>(<a class="code" href="class_g_c_f_1_1_initialize_event.html">GCF::InitializeEvent</a> *e) {</div>
<div class="line">        <span class="keywordflow">if</span>(e-&gt;<a class="code" href="class_g_c_f_1_1_initialize_event.html#a4b61e463cf081b95e8e227d6a28f60ef">isPreInitialize</a>())</div>
<div class="line">            <span class="keywordflow">return</span>;</div>
<div class="line"> </div>
<div class="line">        <a class="code" href="class_g_c_f_1_1_object_tree_node.html">GCF::ObjectTreeNode</a> *node = gAppService-&gt;objectTree()-&gt;node(<span class="keyword">this</span>);</div>
<div class="line">        <span class="keywordflow">if</span>(node)</div>
<div class="line">            node-&gt;<a class="code" href="class_g_c_f_1_1_object_tree_node.html#adc02d2bee38a471d8f639f2fa9da47ed">writableInfo</a>()[<span class="stringliteral">&quot;allowmetaaccess&quot;</span>] = <span class="keyword">true</span>;</div>
<div class="line">    }</div>
<div class="line"> </div>
<div class="line">    <span class="keywordtype">void</span> <a class="code" href="class_g_c_f_1_1_component.html#a7b9e7071c2f4b483a4ee51b08b70835c">contentLoadEvent</a>(<a class="code" href="class_g_c_f_1_1_content_load_event.html">GCF::ContentLoadEvent</a> *e) {</div>
<div class="line">        <span class="keywordflow">if</span>(e-&gt;<a class="code" href="class_g_c_f_1_1_content_load_event.html#a033302e12daeb121564490a8f794417f">isPreContentLoad</a>())</div>
<div class="line">            e-&gt;<a class="code" href="class_g_c_f_1_1_content_load_event.html#a9a6a2ddca167a46d10d76111f64777e1">setContentFile</a>(<span class="stringliteral">&quot;:/Content/SimpleCoreComponent.xml&quot;</span>);</div>
<div class="line">        <a class="code" href="class_g_c_f_1_1_component.html#a7b9e7071c2f4b483a4ee51b08b70835c">GCF::Component::contentLoadEvent</a>(e);</div>
<div class="line">    }</div>
<div class="line"> </div>
<div class="line">    QObject *<a class="code" href="class_g_c_f_1_1_component.html#aa764b26829ba318385b3921bf2b1800a">loadObject</a>(<span class="keyword">const</span> QString &amp;name, <span class="keyword">const</span> QVariantMap &amp;) {</div>
<div class="line">        <span class="keywordflow">if</span>(name == <span class="stringliteral">&quot;Core&quot;</span>)</div>
<div class="line">            <span class="keywordflow">return</span> <span class="keyword">this</span>;</div>
<div class="line">        <span class="keywordflow">return</span> 0;</div>
<div class="line">    }</div>
<div class="line">};</div>
</div><!-- fragment --><p>In SimpleCoreComponent.cpp</p>
<div class="fragment"><div class="line"><span class="preprocessor">#include &quot;SimpleCoreComponent.h&quot;</span></div>
<div class="line"> </div>
<div class="line">GCF_EXPORT_COMPONENT(SimpleCoreComponent)</div>
</div><!-- fragment --><h2><a class="anchor" id="gcf_fiber_3_sub1"></a>
Sample gui service component</h2>
<p>In SimpleGuiComponent.h</p>
<div class="fragment"><div class="line"><span class="preprocessor">#include &lt;GCF3/GuiComponent&gt;</span></div>
<div class="line"> </div>
<div class="line"><span class="keyword">class </span>SimpleGuiComponent : <span class="keyword">public</span> <a class="code" href="class_g_c_f_1_1_gui_component.html">GCF::GuiComponent</a></div>
<div class="line">{</div>
<div class="line">    Q_OBJECT</div>
<div class="line"> </div>
<div class="line"><span class="keyword">public</span>:</div>
<div class="line">    SimpleGuiComponent(QObject *parent = 0)</div>
<div class="line">        :GCF::<a class="code" href="class_g_c_f_1_1_gui_component.html#a07e764a562147615da48972af9079f3d">GuiComponent</a>(parent) {</div>
<div class="line">    }</div>
<div class="line">    </div>
<div class="line">    Q_INVOKABLE <span class="keywordtype">void</span> dummyService() { }</div>
<div class="line"> </div>
<div class="line"><span class="keyword">protected</span>:</div>
<div class="line">    <span class="keywordtype">void</span> <a class="code" href="class_g_c_f_1_1_component.html#a75422842587613d43844e73fb8ca021d">initializeEvent</a>(<a class="code" href="class_g_c_f_1_1_initialize_event.html">GCF::InitializeEvent</a> *e) {</div>
<div class="line">        <span class="keywordflow">if</span>(e-&gt;<a class="code" href="class_g_c_f_1_1_initialize_event.html#a4b61e463cf081b95e8e227d6a28f60ef">isPreInitialize</a>())</div>
<div class="line">            <span class="keywordflow">return</span>;</div>
<div class="line"> </div>
<div class="line">        <a class="code" href="class_g_c_f_1_1_object_tree_node.html">GCF::ObjectTreeNode</a> *node = gAppService-&gt;objectTree()-&gt;node(<span class="keyword">this</span>);</div>
<div class="line">        <span class="keywordflow">if</span>(node)</div>
<div class="line">            node-&gt;<a class="code" href="class_g_c_f_1_1_object_tree_node.html#adc02d2bee38a471d8f639f2fa9da47ed">writableInfo</a>()[<span class="stringliteral">&quot;allowmetaaccess&quot;</span>] = <span class="keyword">true</span>;</div>
<div class="line">    }</div>
<div class="line"> </div>
<div class="line">    <span class="keywordtype">void</span> <a class="code" href="class_g_c_f_1_1_component.html#a7b9e7071c2f4b483a4ee51b08b70835c">contentLoadEvent</a>(<a class="code" href="class_g_c_f_1_1_content_load_event.html">GCF::ContentLoadEvent</a> *e) {</div>
<div class="line">        <span class="keywordflow">if</span>(e-&gt;<a class="code" href="class_g_c_f_1_1_content_load_event.html#a033302e12daeb121564490a8f794417f">isPreContentLoad</a>())</div>
<div class="line">            e-&gt;<a class="code" href="class_g_c_f_1_1_content_load_event.html#a9a6a2ddca167a46d10d76111f64777e1">setContentFile</a>(<span class="stringliteral">&quot;:/Content/SimpleGuiComponent.xml&quot;</span>);</div>
<div class="line">        <a class="code" href="class_g_c_f_1_1_component.html#a7b9e7071c2f4b483a4ee51b08b70835c">GCF::GuiComponent::contentLoadEvent</a>(e);</div>
<div class="line">    }</div>
<div class="line"> </div>
<div class="line">    QObject *<a class="code" href="class_g_c_f_1_1_component.html#aa764b26829ba318385b3921bf2b1800a">loadObject</a>(<span class="keyword">const</span> QString &amp;name, <span class="keyword">const</span> QVariantMap &amp;) {</div>
<div class="line">        <span class="keywordflow">if</span>(name == <span class="stringliteral">&quot;Core&quot;</span>)</div>
<div class="line">            <span class="keywordflow">return</span> <span class="keyword">this</span>;</div>
<div class="line"> </div>
<div class="line">        <span class="keywordflow">return</span> 0;</div>
<div class="line">    }</div>
<div class="line">};</div>
</div><!-- fragment --><p>In SimpleGuiComponent.cpp</p>
<div class="fragment"><div class="line"><span class="preprocessor">#include &quot;SimpleGuiComponent.h&quot;</span></div>
<div class="line"> </div>
<div class="line">GCF_EXPORT_COMPONENT(SimpleGuiComponent)</div>
</div><!-- fragment --><h1><a class="anchor" id="gcf_fiber_4"></a>
Fiber message format</h1>
<hr  />
<p>There are mainly 3 different types of messages that the Fiber recognizes. They are </p><ul>
<li><a class="el" href="gcf_fiber.html#gcf_fiber_2_sub0">Session management request</a> </li>
<li><a class="el" href="gcf_fiber.html#gcf_fiber_2_sub1">Service invocation request</a> </li>
<li><a class="el" href="gcf_fiber.html#gcf_fiber_2_sub2">Meta method invocation request</a></li>
</ul>
<dl class="section note"><dt>Note</dt><dd>Some of the message formats discussed below makes use of an <b>integer</b> field called <b>requestID</b>. It might be a better idea to treat it as a <b>string</b> value at the client end, for reliable cross-platform cross-architecture behaviour (as in, store it as a string and don't engage in an integer like manipulation on the same).</dd></dl>
<h2><a class="anchor" id="gcf_fiber_2_sub0"></a>
Session management request</h2>
<p>Session management request messages can be used to request the Fiber for the creation or termination of a dedicated session. Refer to the table below for the message format for constructing a session management request.</p>
<dl class="section note"><dt>Note</dt><dd>Sessions created like this would be terminated only when an explicit terminate request on that session is made. However if you suspect that you would be dealing with irresponsible clients, you should consider configuring the session handler to terminate on a time-out. See <a class="el" href="gcf_fiber.html#gcf_fiber_6">Advanced tweaking</a></dd></dl>
<table class="doxtable">
<tr>
<th>Request parameters  </th></tr>
<tr>
<td><b>Key</b> </td><td><b>Data-type</b> </td><td><b>Possible values</b>  </td></tr>
<tr>
<td>requestType  </td><td>string  </td><td><b>SESSION_MGMT</b>   </td></tr>
<tr>
<td>sessionCommand  </td><td>string  </td><td><b>create</b> - to create a session <br  />
 <b>terminate</b> - to terminate a session   </td></tr>
<tr>
<td>sessionName  </td><td>string  </td><td><p class="starttd"><b>ID</b> of the session that needs to be terminated. Needs to be specified only for <b>terminate</b> requests </p>
<p class="endtd"></p>
</td></tr>
<tr>
<th>Response parameters  </th></tr>
<tr>
<td><b>Key</b> </td><td><b>Data-type</b> </td><td><b>Possible values</b>  </td></tr>
<tr>
<td>success  </td><td>bool  </td><td><b>true</b> - if session created successfully <br  />
 <b>false</b> - if session creation failed   </td></tr>
<tr>
<td>result  </td><td>string  </td><td><b>ID</b> of the created session on success; empty string otherwise   </td></tr>
<tr>
<td>error  </td><td>string  </td><td><b>error message</b> on failure; empty string otherwise   </td></tr>
</table>
<h2><a class="anchor" id="gcf_fiber_2_sub1"></a>
Service invocation request</h2>
<p>Service invocation requests can be made to the Fiber, to request it to invoke a service and return its response. Depending on whether the request is made as a blocking call or not, Fiber would respond either with the actual result or a requestID which can be used to retrieve the result when it becomes available. We recommend that you use "non-blocking" calls as much as possible, and resort to the "blocking" calls only in the case of extremely simple service methods. Refer to the table below for the message format that is expected.</p>
<dl class="section note"><dt>Note</dt><dd>To see how to retrieve the result of a non-blocking call see <a class="el" href="gcf_fiber.html#gcf_fiber_2_sub2">Meta method invocation request</a></dd></dl>
<table class="doxtable">
<tr>
<th>Request parameters  </th></tr>
<tr>
<td><b>Key</b> </td><td><b>Data-type</b> </td><td><b>Possible values</b>  </td></tr>
<tr>
<td>requestType  </td><td>string  </td><td><b>SERVICE_REQUEST</b>   </td></tr>
<tr>
<td>sessionType  </td><td>string  </td><td><b>CORE</b> - to invoke service on a core only session <br  />
 <b>GUI</b> - to invoke service on a gui session   </td></tr>
<tr>
<td>sessionName  </td><td>string  </td><td><b>ID</b> of the session to be used. Leave blank / exclude this field to invoke service on the default session, but this is not recommended   </td></tr>
<tr>
<td>blockingCall  </td><td>bool  </td><td><b>true</b> - if the response should contain the result of invocation <br  />
 <b>false</b> - to receive a requestID as response, which can be used to retrieve the actual response when it becomes available   </td></tr>
<tr>
<td>serviceLibrary  </td><td>string  </td><td>Name of the library file that contains the component   </td></tr>
<tr>
<td>serviceComponent  </td><td>string  </td><td>Name of the component that contains the service   </td></tr>
<tr>
<td>serviceObject  </td><td>string  </td><td>Name of the object in the component that implements the service   </td></tr>
<tr>
<td>serviceMethod  </td><td>string  </td><td>Name of the service method  </td></tr>
<tr>
<td>args  </td><td>list  </td><td><p class="starttd">Array of arguments (maximum 9) to be supplied to the service method.<br  />
 Contents of the list could be a mix of any of the following types - bool, int, double, string, list, map <br  />
Exclude this parameter if the service method doesn't have a parameter  </p>
<p class="endtd"></p>
</td></tr>
<tr>
<th>Response parameters  </th></tr>
<tr>
<td><b>Key</b> </td><td><b>Data-type</b> </td><td><b>Possible values</b>  </td></tr>
<tr>
<td>success  </td><td>bool  </td><td><b>true</b> - if the service method was invoked successfully <br  />
 <b>false</b> - if service invocation failed   </td></tr>
<tr>
<td>result  </td><td>bool / int / double / string / list / map  </td><td><b>requestID</b> - if the request was not a blocking one <br  />
 <b> result of service method </b> - if the request was a blocking call   </td></tr>
<tr>
<td>error  </td><td>string  </td><td><b>error message</b> on failure; empty string otherwise   </td></tr>
</table>
<h2><a class="anchor" id="gcf_fiber_2_sub2"></a>
Meta method invocation request</h2>
<p>This kind of requests can be made to invoke some meta methods on the Fiber. Right now, the meta methods available on the Fiber deals with retrieving the results of non-blocking calls made using <a class="el" href="gcf_fiber.html#gcf_fiber_2_sub1">Service invocation request</a>. It can also be used to cancel any of the previously made non-blocking requests, for which the results are not downloaded yet.</p>
<table class="doxtable">
<tr>
<th>Request parameters  </th></tr>
<tr>
<td><b>Key</b> </td><td><b>Data-type</b> </td><td><b>Possible values</b>  </td></tr>
<tr>
<td>requestType  </td><td>string  </td><td><b>SERVICE_REQUEST</b>   </td></tr>
<tr>
<td>sessionType  </td><td>string  </td><td><b>CORE</b> - to invoke service on a core only session <br  />
 <b>GUI</b> - to invoke service on a gui session   </td></tr>
<tr>
<td>sessionName  </td><td>string  </td><td><b>ID</b> of the session to be used. Leave blank / exclude this field to invoke service on the default session, but this is not recommended   </td></tr>
<tr>
<td>metaCall  </td><td>bool  </td><td><b>true</b>   </td></tr>
<tr>
<td>metaMethod  </td><td>string  </td><td><b>availableResponses</b> - to retrieve the list of requestIDs for which results are available <br  />
 <b>responseSize</b> - to retrieve the size of response available for the specified requestID <br  />
 <b>response</b> - to retrieve the <b> specified chunk </b> of response for specified requestID <br  />
 <b>cancelRequests</b> - to cancel the non-blocking method invocation requests for specified list of requestIDs   </td></tr>
<tr>
<td>requestID  </td><td>int  </td><td>requestID to be used. <b>Only</b> for <b>responseSize</b> and <b>response</b> meta call   </td></tr>
<tr>
<td>requestIDs  </td><td>list  </td><td>list of requestIDs to be used. <b>Only</b> for <b>cancelRequests</b> meta call.   </td></tr>
<tr>
<td>responseLength  </td><td>int  </td><td><p class="starttd"><b>chunk size</b> in bytes. This is the size of response that would be retrieved from the response available at Fiber. The specified size is sliced from the beginning of response available at the Fiber, and sent back to the client. <br  />
 <b>Only</b> required while making <b>response</b> meta call. <br  />
 Excluding this parameter or specifying -1 as value would result in retrieving the entire response available; and this is not recommended  </p>
<p class="endtd"></p>
</td></tr>
<tr>
<th>Response parameters  </th></tr>
<tr>
<td><b>Key</b> </td><td><b>Data-type</b> </td><td><b>Possible values</b>  </td></tr>
<tr>
<td>success  </td><td>bool  </td><td><b>true</b> - if the service method was invoked successfully <br  />
 <b>false</b> - if service invocation failed   </td></tr>
<tr>
<td>result  </td><td>int / string / list  </td><td>Depending on the meta call the result would contain one of the following <br  />
<ul>
<li>list of requestIDs for which results are available <br  />
</li>
<li>size of response available (in bytes) for a requestID <br  />
</li>
<li>chunk of response requested <br  />
</li>
<li>list of requestIDs which were cancelled successfully   </li>
</ul>
</td></tr>
<tr>
<td>error  </td><td>string  </td><td><b>error message</b> on failure; empty string otherwise   </td></tr>
</table>
<h1><a class="anchor" id="gcf_fiber_5"></a>
Accessing Fiber using the message format</h1>
<hr  />
<p>Clients can be written to communicate with Fiber in <b>any technology</b> as long as it is possible to</p><ul>
<li>make HTTP requests and receive the corresponding responses</li>
<li>create and interpret JSON objects, represent JSON objects as strings, and construct JSON objects from string.</li>
</ul>
<p>The ideal flow of events in a client would be</p><ul>
<li>A JSON object, with the necessary key=value pair entries must be created (based on <a class="el" href="gcf_fiber.html#gcf_fiber_4">Fiber message format</a>).</li>
<li>The JSON object created in the above step should be converted to a string.</li>
<li>Send the above mentioned string as a request by making an HTTP post request to the address in which Fiber is listening.</li>
<li>Wait for the HTTP response to be available and read it completely.</li>
<li>Treat the received data as plain text, and attempt to create a JSON object out of it.</li>
<li>If the above step succeed, you must be able to extract the result from the object; in the format specified for the corresponding request as discussed in <a class="el" href="gcf_fiber.html#gcf_fiber_4">Fiber message format</a>.</li>
</ul>
<dl class="section note"><dt>Note</dt><dd>Clients should be making requests to the following address <b><a href="http://your-webserver:port/FiberScript.php">http://your-webserver:port/FiberScript.php</a></b></dd></dl>
<h1><a class="anchor" id="gcf_fiber_6"></a>
Advanced tweaking</h1>
<hr  />
<p>Fiber has some configuration options at the server side that can be tweaked and tuned to some extent, so that it can adapt to your requirements.</p>
<h2><a class="anchor" id="gcf_fiber_6_sub0"></a>
Configuration settings</h2>
<p>The session handler at the Fiber can be configured to terminate automatically, if it remains idle for a specific amount of time. This can be configured by editing the <b>path-toGCF3/Binary/FiberConfig/FiberRequestHandler.ini</b> file.</p>
<h2><a class="anchor" id="gcf_fiber_6_sub1"></a>
Hooks in PHP script</h2>
<p>Fiber has provisions for inserting additional policing of requests, like security check, before Fiber handles any data. There are hooks from the Fiber's PHP scripts that would be invoked, before and after processing any request received. You could place calls to your own routines, in these hooks so that additional features like security checking can be implemented, if necessary. To do this refer to the file <b>path-to-GCF3/Fiber/Fiber/Scripts/FiberAccessHooks.php</b>. <br  />
 <br  />
 - <em>postReceiveRequest</em> will be called immediately after receiving the request. <br  />
 - <em>postProcessRequest</em> will be called immediately after processing the request and before sending the response to the client. <br  />
 - <em>postSendResponse</em> will be called immediately after sending the response to the client </p>
</div></div><!-- contents -->
</div><!-- PageDoc -->
<div class="ttc" id="aclass_g_c_f_1_1_object_tree_node_html_adc02d2bee38a471d8f639f2fa9da47ed"><div class="ttname"><a href="class_g_c_f_1_1_object_tree_node.html#adc02d2bee38a471d8f639f2fa9da47ed">GCF::ObjectTreeNode::writableInfo</a></div><div class="ttdeci">QVariantMap &amp; writableInfo()</div><div class="ttdef"><b>Definition:</b> ObjectTree.cpp:499</div></div>
<div class="ttc" id="aclass_g_c_f_1_1_component_html_a7b9e7071c2f4b483a4ee51b08b70835c"><div class="ttname"><a href="class_g_c_f_1_1_component.html#a7b9e7071c2f4b483a4ee51b08b70835c">GCF::Component::contentLoadEvent</a></div><div class="ttdeci">virtual void contentLoadEvent(GCF::ContentLoadEvent *e)</div><div class="ttdef"><b>Definition:</b> Component.cpp:1041</div></div>
<div class="ttc" id="aclass_g_c_f_1_1_gui_component_html"><div class="ttname"><a href="class_g_c_f_1_1_gui_component.html">GCF::GuiComponent</a></div><div class="ttdoc">Extends GCF::Component to ease creation of GUI components.</div><div class="ttdef"><b>Definition:</b> GuiComponent.h:35</div></div>
<div class="ttc" id="aclass_g_c_f_1_1_content_load_event_html_a033302e12daeb121564490a8f794417f"><div class="ttname"><a href="class_g_c_f_1_1_content_load_event.html#a033302e12daeb121564490a8f794417f">GCF::ContentLoadEvent::isPreContentLoad</a></div><div class="ttdeci">bool isPreContentLoad() const</div><div class="ttdef"><b>Definition:</b> Component.h:166</div></div>
<div class="ttc" id="aclass_g_c_f_1_1_component_html"><div class="ttname"><a href="class_g_c_f_1_1_component.html">GCF::Component</a></div><div class="ttdoc">Base class for all GCF components.</div><div class="ttdef"><b>Definition:</b> Component.h:52</div></div>
<div class="ttc" id="aclass_g_c_f_1_1_component_html_a0a8e6280e3029cab1db39d4a0b0cdf11"><div class="ttname"><a href="class_g_c_f_1_1_component.html#a0a8e6280e3029cab1db39d4a0b0cdf11">GCF::Component::Component</a></div><div class="ttdeci">Component(QObject *parent=nullptr)</div><div class="ttdef"><b>Definition:</b> Component.cpp:418</div></div>
<div class="ttc" id="aclass_g_c_f_1_1_component_html_a75422842587613d43844e73fb8ca021d"><div class="ttname"><a href="class_g_c_f_1_1_component.html#a75422842587613d43844e73fb8ca021d">GCF::Component::initializeEvent</a></div><div class="ttdeci">virtual void initializeEvent(GCF::InitializeEvent *e)</div><div class="ttdef"><b>Definition:</b> Component.cpp:819</div></div>
<div class="ttc" id="aclass_g_c_f_1_1_gui_component_html_a07e764a562147615da48972af9079f3d"><div class="ttname"><a href="class_g_c_f_1_1_gui_component.html#a07e764a562147615da48972af9079f3d">GCF::GuiComponent::GuiComponent</a></div><div class="ttdeci">GuiComponent(QObject *parent=nullptr)</div><div class="ttdef"><b>Definition:</b> GuiComponent.cpp:165</div></div>
<div class="ttc" id="aclass_g_c_f_1_1_object_tree_node_html"><div class="ttname"><a href="class_g_c_f_1_1_object_tree_node.html">GCF::ObjectTreeNode</a></div><div class="ttdoc">Represents a node in GCF::ObjectTree.</div><div class="ttdef"><b>Definition:</b> ObjectTree.h:111</div></div>
<div class="ttc" id="aclass_g_c_f_1_1_content_load_event_html"><div class="ttname"><a href="class_g_c_f_1_1_content_load_event.html">GCF::ContentLoadEvent</a></div><div class="ttdoc">Contains parameters that describe a content-load event.</div><div class="ttdef"><b>Definition:</b> Component.h:158</div></div>
<div class="ttc" id="aclass_g_c_f_1_1_component_html_aa764b26829ba318385b3921bf2b1800a"><div class="ttname"><a href="class_g_c_f_1_1_component.html#aa764b26829ba318385b3921bf2b1800a">GCF::Component::loadObject</a></div><div class="ttdeci">virtual QObject * loadObject(const QString &amp;name, const QVariantMap &amp;info)</div><div class="ttdef"><b>Definition:</b> Component.cpp:1640</div></div>
<div class="ttc" id="aclass_g_c_f_1_1_initialize_event_html_a4b61e463cf081b95e8e227d6a28f60ef"><div class="ttname"><a href="class_g_c_f_1_1_initialize_event.html#a4b61e463cf081b95e8e227d6a28f60ef">GCF::InitializeEvent::isPreInitialize</a></div><div class="ttdeci">bool isPreInitialize() const</div><div class="ttdef"><b>Definition:</b> Component.h:132</div></div>
<div class="ttc" id="aclass_g_c_f_1_1_content_load_event_html_a9a6a2ddca167a46d10d76111f64777e1"><div class="ttname"><a href="class_g_c_f_1_1_content_load_event.html#a9a6a2ddca167a46d10d76111f64777e1">GCF::ContentLoadEvent::setContentFile</a></div><div class="ttdeci">void setContentFile(const QString &amp;fileName)</div><div class="ttdef"><b>Definition:</b> Component.h:169</div></div>
<div class="ttc" id="aclass_g_c_f_1_1_initialize_event_html"><div class="ttname"><a href="class_g_c_f_1_1_initialize_event.html">GCF::InitializeEvent</a></div><div class="ttdoc">Contains parameters that describe an initialization event.</div><div class="ttdef"><b>Definition:</b> Component.h:124</div></div>
</div>
</div>
</div>
<div class="footer_content">
<table width="100%" class="footer">
<tr>
<td align="left" width="50%">Copyright &copy; 2013-2019,
 <a class="el" href="http://www.vcreatelogic.com" target="_black">VCreate Logic Private Limited</a></td>
<td align="right" width="50%"><a class="el" href="http://www.vcreatelogic.com/products/gcf" target="_black">GCF - Generic Component Framework</a></td>
</tr>
</table>
</div>
</div>
</body>
</html>
